home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 2⁄16⁄90 / 0681-PrintHandler in many-Feb90 < prev    next >
Encoding:
Text File  |  1990-02-16  |  2.6 KB  |  74 lines  |  [TEXT/GEOL]

  1. Item    5430486                         15-Feb-90        09:58PST
  2.  
  3. From:   MUYSVASOVIC                     ACE - Jean-Denis Muys-Vasovic
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. cc:     RANSON                          France - Dev, Ranson Lannion,IDV
  8.  
  9. Sub:    PrintHandler in many views
  10.  
  11. Hello folks, any idea about this one?
  12.  
  13. My document is able to display the same data is lot of different manners in
  14. different windows. In DoMakeViews, I default to making, say, TView1. At any
  15. given time I may have TView1, Tview2, and TView3 open. All of them has a print
  16. handler, and should be able to print. The problem with TView3 is that it is
  17. located in the same window as an EditText which IS the target. The net effect
  18. is that when I choose print in the File menu, it is handled by the document who
  19. asks its handler to print, and its handler is the first one created, namely the
  20. one printing TView1.
  21.  
  22. In short: TView3 is in front, and TView1 gets printed!!
  23.  
  24. What would be the best solution to handle that? I don't want to insert the
  25. TView3 in the target chain. I tried the following too clever solution: I stuff
  26. the print handler in the window as well as the TView1 when TView1 is created:
  27.  
  28. TMyDocument.CreateTheView(aCmdNumber: CmdNumber);
  29. BEGIN
  30. aWindow := NewTemplateWindow(aCmdNumber, SELF);
  31. aView := aWindow.FindSubView('work');
  32. FailNil(aView);
  33. New(aHandler);
  34. FailNil(aHandler);
  35. aHandler.IHandler(SELF, aView, …);
  36. aWindow.AttachPrintHandler(aHandler);
  37. END;
  38.  
  39. This makes sense because the window is generally never printed as a window, and
  40. yet it is in the target chain. This "almost" works. What doesn't work is:
  41.  
  42. TView.Free tries to free fPrintHandler if non-nil. The print handler is
  43. therefore freed twice. I suggest TView.Free would also test fPrintHandler.fView
  44. = SELF.
  45.  
  46. At a number of circumstances, methods of TView use fPrintHandler for a number
  47. of things. These methods are usually not overriden in TWindow, but are harmless
  48. because TWindow.fPrintHandler is almost always nil. In my case the net result
  49. is AssumeFocused breaks a number of times!! (This also makes sense). However,
  50. if I go, the view gets printed correctly!!
  51.  
  52. Suggestion: Allow for the same printhandler (to print a unique given view) to
  53. be attached to several views. This would only amounts to guard all the messages
  54. sent to fPrintHandler in TView by the test: IF fPrintHandler.fView = SELF THEN…
  55.  
  56. Does all this make sense? Do you have any other solution which wouldn't involve
  57. modifying MacApp source code? Did I miss something obvious?
  58.  
  59. With all my very best regards, I remain as much as James,
  60.  
  61. Yours.
  62.  
  63.  
  64. Jean-Denis
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.